home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Full / NetObjects Fusion 9 Standard / NOF9_Full_EN.exe / data1.cab / Resources / flash / FlashCtrl.js < prev    next >
Encoding:
Text File  |  2005-11-16  |  37.4 KB  |  1,265 lines

  1. /*
  2.   @todo The NOF_NS init needs to be moved out to a shared JS that gets loaded prior to all
  3.   its clients using it. Right now is just Flash but will likely add more in the future. For instances
  4.   DB could inject in the same name space. It simply uses now NOF_xxxx
  5.  
  6.   @todo: refine it further by moving the navbar specifics to a subclass
  7.  
  8.   @see http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701 for OBJECT/EMBED attributes
  9. */
  10. if(typeof NOF == "undefined") {
  11.   function NOF_NS() {
  12.       this.__proto__ = NOF_NS.prototype;
  13.   }
  14. }
  15.  
  16. var NOF = new NOF_NS();
  17.  
  18. if(typeof NOF.ProgramVersion == "undefined")
  19. {
  20.  
  21.   function NOF_ProgramVersion (majorNumber, minorNumber, revisionNumber) {
  22.       this.__proto__ = NOF_ProgramVersion.prototype;
  23.  
  24.       if (arguments.length != 3) throw "Illegal arguments exception";
  25.  
  26.       this.majorNumber    = majorNumber;
  27.       this.minorNumber    = minorNumber;
  28.       this.revisionNumber = revisionNumber;
  29.   }
  30.  
  31.   {
  32.     var method = NOF_ProgramVersion.prototype;
  33.  
  34.     method.getMajorNumber = function () {
  35.       return this.majorNumber;
  36.     }
  37.  
  38.     method.getMinorNumber = function () {
  39.       return this.minorNumber;
  40.     }
  41.  
  42.     method.getRevisionNumber = function () {
  43.       return this.revisionNumber;
  44.     }
  45.  
  46.     method.eq = function (programVersion) {
  47.       return  this.majorNumber == programVersion.getMajorNumber()
  48.               && this.minorNumber == programVersion.getMinorNumber()
  49.               && this.revisionNumber == programVersion.getRevisionNumber();
  50.     }
  51.  
  52.     method.lt = function (programVersion) {
  53.       var retValue = false;
  54.  
  55.       if (this.majorNumber < programVersion.getMajorNumber() ) {
  56.           retValue = true;
  57.       } else if (this.majorNumber == programVersion.getMajorNumber()) {
  58.           if (this.minorNumber < programVersion.getMinorNumber()) {
  59.             retValue = true;
  60.           } else if (this.minorNumber == programVersion.getMinorNumber()) {
  61.             if (this.revisionNumber < programVersion.getRevisionNumber()) {
  62.               retValue = true;
  63.             }
  64.           }
  65.       }
  66.  
  67.       return retValue;
  68.     }
  69.  
  70.     method.lte = function (programVersion) {
  71.       return this.lt(programVersion) && this.eq(programVersion);
  72.     }
  73.  
  74.     method.gt = function (programVersion) {
  75.       return !this.lte(programVersion);
  76.     }
  77.  
  78.     method.gte = function (programVersion) {
  79.       return !this.lt(programVersion);
  80.     }
  81.  
  82.     method.toString = function () {
  83.       return this.majorNumber + "." + this.minorNumber + "." + this.revisionNumber;
  84.     }
  85.  
  86.   }
  87.  
  88.   NOF.__proto__.ProgramVersion = NOF_ProgramVersion;
  89. }
  90.  
  91.  
  92. if (typeof NOF.Util == "undefined") {
  93.  
  94.   function NOF_Util() {
  95.     this.__proto__ = NOF_Util.prototype;
  96.   }
  97.  
  98.   NOF.Util = new NOF_Util();
  99.  
  100.   function NOF_Util_FramesIterator (wnd) {
  101.     this.__proto__ =  NOF_Util_FramesIterator.prototype;
  102.     this.currentIndex = 0;
  103.     this.array = wnd.frames;
  104.  
  105.     NOF_Util_FramesIterator.prototype.next = function () {
  106.       return (this.currentIndex < this.array.length ) ? this.array[this.currentIndex++] : null;
  107.     }
  108.   }
  109.  
  110.   NOF.Util.__proto__.FramesIterator = NOF_Util_FramesIterator;
  111.  
  112.   NOF.Util.GetFrameWndByName = function GetFrameWndByName(name) {
  113.     var stack = new Array();
  114.     stack[0] = new NOF.Util.FramesIterator(window);
  115.     var wnd = null;
  116.     var found = false;
  117.     while (stack.length > 0 && !found)
  118.     {
  119.       if ((wnd = stack[stack.length -1].next()) != null)
  120.       {
  121.         if (wnd.name == name)
  122.         {
  123.           found = true;
  124.           break;
  125.         }
  126.         else if (wnd.frames.length > 0)
  127.         {
  128.           stack[stack.length] = new NOF.Util.FramesIterator(wnd);
  129.         }
  130.       }
  131.       else
  132.       {
  133.         stack[stack.length-1] = null;
  134.         stack.length--;
  135.       }
  136.     }
  137.  
  138.     return wnd;
  139.   }
  140. }
  141.  
  142. if(typeof NOF.Event == "undefined") {
  143.   function NOF_Event(source, type, state) {
  144.     this.__proto__ = NOF_Event.prototype;
  145.     this.source = source;
  146.     this.type = type;
  147.     this.state = state;
  148.   }
  149.  
  150.   var member = NOF_Event.prototype;
  151.  
  152.   member.MOUSEDOWN_EVENT   = 0x001;
  153.   member.MOUSEUP_EVENT     = 0x002;
  154.   member.MOUSEMOVE_EVENT   = 0x004;
  155.   member.MOVIE_INITIALIZED_EVENT = 0x008;
  156.  
  157.   var method = NOF_Event.prototype;
  158.  
  159.   method.getSource = function() {
  160.     return this.source;
  161.   };
  162.  
  163.   method.getType = function() {
  164.     return this.type;
  165.   };
  166.  
  167.   method.getState = function() {
  168.     return this.state;
  169.   };
  170.  
  171.   NOF.Event = new NOF_Event();
  172.   NOF.EventObject = NOF_Event;
  173. }
  174.  
  175.  
  176. if(typeof NOF.Flash == "undefined") {
  177.   function NOF_Flash() {
  178.       this.__proto__ = NOF_Flash.prototype;
  179.   }
  180.  
  181.   NOF.Flash = new NOF_Flash();
  182. }
  183.  
  184.  
  185. if(typeof NOF.Flash.HtmlCtrl == "undefined")
  186. {
  187.  
  188.   function NOF_Flash_HtmlCtrl_Base()
  189.   {
  190.     this.__proto__ = NOF_Flash_HtmlCtrl_Base.prototype;
  191.   }
  192.  
  193.   {
  194.     var member = NOF_Flash_HtmlCtrl_Base.prototype;
  195.     //add static members here
  196.  
  197.     member.MOVIE_LISTENER             = 0x001;
  198.     member.MOUSE_LISTENER             = 0x002;
  199.     member.NETSCAPE_PLUGIN_NAME       = "Shockwave Flash";
  200.     member.IE_PLUGIN_NAME             = "ShockwaveFlash.ShockwaveFlash";
  201.     member.FOOTPRINT_SUFFIX           = "_footprint";
  202.     member.CONTAINER_SUFFIX           = "_container";
  203.     member.LAYER_SUFFIX               = "LYR";
  204.  
  205.     member.PARAM_ALLOWSCRIPTACCESS    = "allowScriptAccess";
  206.     member.PARAM_QUALITY              = "quality";
  207.     member.PARAM_WMODE                = "wmode";
  208.  
  209.     member.DEFAULT_QUALITY_VALUE      = "high";
  210.     member.DEFAULT_WMODE_VALUE        = "transparent";
  211.     member.cDELTA                     = 5; //compensantion delta for dimensions variations
  212.     member.DEFAULT_HIGHEST_ZINDEX     = 2000;
  213.  
  214.     var method = NOF_Flash_HtmlCtrl_Base.prototype;
  215.  
  216.     method.ctr = function ( id, movieSrc, width, height, align, htmlDocument) {
  217.  
  218.       //verify preconditions in case this is not the default constructor call
  219.       if (arguments.length > 0) {
  220.         if (id == undefined || id.length <=0 ) {
  221.         throw "IllegalArgumentException: id cannot be empty";
  222.         }
  223.  
  224.         if (movieSrc == undefined || movieSrc.length <=0 ) {
  225.           throw "IllegalArgumentException: movieSrc cannot be null";
  226.         }
  227.       }
  228.  
  229.     this.movieListeners= new Array();
  230.       this.mouseListeners= new Array();
  231.       this.params       = new Array();
  232.       this.variables    = new Array();
  233.  
  234.       this.id           = id;
  235.       this.movieSrc     = movieSrc;
  236.  
  237.       this.width        = (width    != null) ? width    : null;
  238.       this.height       = (height   != null) ? height   : null;
  239.       this.align        = (align    != null) ? align    : null;
  240.  
  241.       this.htmlDocument = (htmlDocument != undefined) ?  htmlDocument : document;
  242.  
  243.       this.position     = {left : -1, top: -1};
  244.  
  245.  
  246.       this.isFSCEventsSupportEnabled = true;
  247.       this.areFSCEventsEnabled       = true;
  248.  
  249.       //enable scripts access within the same domain by default so getURL and fsCommands succeed
  250.       this.setParam(this.PARAM_ALLOWSCRIPTACCESS, "sameDomain");
  251.  
  252.       //set default params value
  253.       this.setParam(this.PARAM_QUALITY, this.DEFAULT_QUALITY_VALUE);
  254.       this.setParam(this.PARAM_WMODE, this.DEFAULT_WMODE_VALUE);
  255.  
  256.       this.requiredPlayerVersion = "7,0,0,0";
  257.  
  258.       this.closedMenuSize = {width : 0, height: 0};
  259.       this.foHtmlInstance = null;
  260.       this.foContainer = null;
  261.       this.foFootprint = null;
  262.       this.foParentLYR = null;
  263.  
  264.       this.isWritten = false;
  265.       this.bReady   = false;
  266.  
  267.       this.capturedEventsMask = 0;
  268.       this.owner = null;
  269.     }
  270.  
  271.     /*
  272.      * Gets the readiness state.
  273.      *
  274.      * @return true if PostInit event was received and processed succesfully. false otherwise
  275.     */
  276.     method.isReady = function () { return this.bReady;};
  277.  
  278.  
  279.     /*
  280.      *Gets/sets the movie owner
  281.     */
  282.     method.getOwner = function () { return this.owner;};
  283.     method.setOwner = function (owner) { this.owner = owner;};
  284.  
  285.  
  286.     /*
  287.      *Gets/sets the movie width
  288.     */
  289.     method.getWidth = function () { return this.width;};
  290.     method.setWidth = function (width) { this.width = width;};
  291.  
  292.     /*
  293.      * Gets/sets the movie height
  294.     */
  295.     method.getHeight = function () { return this.height;};
  296.     method.setHeight = function (height) { this.height = height;};
  297.  
  298.     /*
  299.      * Gets/sets the movie Position
  300.     */
  301.     method.getPosition = function () { return this.position;};
  302.     method.setPosition = function (position) { this.position = position;};
  303.  
  304.  
  305.     /*
  306.      * Gets/sets the movie source. URLs are expected
  307.     */
  308.     method.getMovieSrc = function () { return this.movieSrc;};
  309.     method.setMovieSrc = function (movieSrc) { this.movieSrc = movieSrc;};
  310.  
  311.  
  312.     /*
  313.      * Gets/sets the html element alignment.
  314.     */
  315.     method.getAlign = function () { return this.align;};
  316.     method.setAlign = function (align) { this.align = align;};
  317.  
  318.     method.getId = function () {return this.id;};
  319.  
  320.     /*
  321.      * Player Parameters getter/setter
  322.      *
  323.      * @note: the names are case insensitive
  324.     */
  325.     method.getParam = function(name) { return this.params[name.toLowerCase()];};
  326.     method.setParam = function(name, value) { this.params[name.toLowerCase()] = value;};
  327.     method.getParams = function() { return this.params; };
  328.  
  329.     /*
  330.      * Variables getter/setter
  331.     */
  332.     method.getVariable = function(name) {return this.variables[name];};
  333.     method.setVariable = function(name, value) { this.variables[name] = value;};
  334.     method.getVariables = function() { return this.variables;};
  335.  
  336.     /*
  337.      * Footprint getter
  338.     */
  339.     method.getFootprint = function() {
  340.       if (!this.foFootprint) {
  341.         this.foFootprint = this.findObject(this.id + this.FOOTPRINT_SUFFIX);
  342.       }
  343.  
  344.       return this.foFootprint;
  345.     };
  346.  
  347.     /*
  348.      * Searches the document's objects collection for a name match. Handles the
  349.      * particular case for NN4 compat generation mode where a collection of two
  350.      * is returned instead of the actual object due to duplicate IDs (<div><ilayer>).
  351.      *
  352.      * @return the parent layer reference if present, null otherwise
  353.     */
  354.     method.getParentLYR = function() {
  355.       if (!this.foParentLYR) {
  356.         this.foParentLYR = this.findObject(this.id + this.LAYER_SUFFIX);
  357.         //if we run in NN4 compat mode (<div><ilayer>) grab the first collection element
  358.         if (this.foParentLYR != null && typeof (this.foParentLYR.length) == 'number') {
  359.           this.foParentLYR = this.foParentLYR[0];
  360.         }
  361.       }
  362.  
  363.       return this.foParentLYR;
  364.     }
  365.  
  366.     /*
  367.      * HtmlInstance getter
  368.     */
  369.     method.getHtmlInstance = function() {
  370.       if (!this.foHtmlInstance) {
  371.         this.foHtmlInstance =  this.findObject(this.id);
  372.       }
  373.  
  374.  
  375.       return this.foHtmlInstance;
  376.     };
  377.  
  378.  
  379.     /*
  380.      * Container getter
  381.     */
  382.     method.getContainer = function() {
  383.       if (!this.foContainer) {
  384.         this.foContainer = this.findObject(this.id + this.CONTAINER_SUFFIX);
  385.       }
  386.  
  387.       return this.foContainer;
  388.     };
  389.  
  390.     /*
  391.      * Sets the state for generating FSCommand support or not. Default is disabled
  392.      *
  393.      * @param enable true to enable it. false to disable support
  394.     */
  395.     method.enableFSCEventsSupport = function (enable) {
  396.       this.isFSCEventsSupportEnabled = enable;
  397.     };
  398.  
  399.     /*
  400.      * Sets the state for processing the fsCommands or not. Default is disabled
  401.      *
  402.      * @param enable true to enable it. false to disable support
  403.     */
  404.     method.enableFSCEvents = function (enable) {
  405.       this.areFSCEventsEnabled = enable;
  406.     };
  407.  
  408.     /*
  409.      * Restarts the movie
  410.      *
  411.     */
  412.     method.restart = function () {
  413.       try {
  414.         this.getHtmlInstance().Rewind();
  415.         this.getHtmlInstance().Play();
  416.         this.log("restarting");
  417.       } catch (e) {}
  418.     };
  419.  
  420.     /*
  421.      * Moves current Flash placeholder to its footprint position
  422.      *
  423.     */
  424.     method.repaint = function () {
  425.         var position = this.getObjectPosition(this.getFootprint());
  426.         this.log("onRepaint -> " + position[0] + ", " + position[1]);
  427.         this.onMove(position[0], position[1]);
  428.     };
  429.  
  430.     /*
  431.      * Moves current Flash placeholder to its footprint position
  432.      *
  433.     */
  434.     method.onRepaint = function () {
  435.       this.repaint();
  436.     };
  437.  
  438.     /*
  439.      * Moves current Flash placeholder on page
  440.      *
  441.      * @param left new absolute left offset
  442.      * @param top new absolute top offset
  443.     */
  444.     method.onMove = function (left, top) {
  445.       //this.log("onMove -> " + left + ", " + top);
  446.  
  447.       this.setStyle("left",left + "px");
  448.       this.setStyle("top", top + "px");
  449.  
  450.       this.position.left = left;
  451.       this.position.top = top;
  452.     };
  453.  
  454.     /*
  455.      *
  456.     */
  457.     method.setStyle = function (name, value, obj) {
  458.       //this.log("setStyle -> " + (obj != null ? obj.id : "")  + ", " + name + ", " + value);
  459.  
  460.       if (!obj) { obj = this.getContainer()}
  461.  
  462.       if (obj != null && typeof(obj.style) == "object") {
  463.         obj.style[name] = value;
  464.       }
  465.     };
  466.  
  467.     /*
  468.      *
  469.     */
  470.     method.getStyle = function (name, obj) {
  471.       if (!obj) { obj = this.getContainer()}
  472.  
  473.       return (obj != null && typeof(obj.style) == "object") ? obj.style[name] : null;
  474.     };
  475.  
  476.  
  477.     /*
  478.      * Resizes current Flash placeholder on page by updating the html attribute
  479.      *
  480.      * @param width new width value
  481.      * @param height new height value
  482.     */
  483.     method.onResize = function (width, height) {
  484.       this.log("onResize -> " + width + ", " + height);
  485.  
  486.       if (width == this.width && height == this.height) return;
  487.  
  488.       this.adjustZIndexOnSizeChange(width, height);
  489.  
  490.       this.width  = width;
  491.       this.height = height;
  492.  
  493.       var htmlInstance = this.getHtmlInstance();
  494.       if (htmlInstance) {
  495.         htmlInstance.width   = width;
  496.         htmlInstance.height  = height;
  497.       }
  498.     };
  499.  
  500.  
  501.     /*
  502.      * Resizes this Flash's associated footprint to current movie dimensions.
  503.      * Also calls the callback if any defined asynchronously via a timer to
  504.      * allow current Flash call to JavaScript to finish.
  505.      *
  506.      * @param width new width value
  507.      * @param height new height value
  508.     */
  509.     method.onPostInit = function (width, height) {
  510.       this.log("PostInit");
  511.  
  512.       this.closedMenuSize.width = width;
  513.       this.closedMenuSize.height = height;
  514.       var parentLYR = this.getParentLYR();
  515.       this.parentZIndex = this.getStyle("zIndex", parentLYR);
  516.  
  517.       if (this.getFootprint()) {
  518.         this.doInitialPositioning(width, height);
  519.         //run the callback async to allow previous play call to finish if any to notify the listener of initialization completion
  520.         NOF.Flash.HtmlCtrl.instancePtr = this;
  521.         setTimeout("if (NOF.Flash.HtmlCtrl.instancePtr && typeof NOF.Flash.HtmlCtrl.instancePtr.doPostInitCallBack == 'function' ) { NOF.Flash.HtmlCtrl.instancePtr.doPostInitCallBack(); };", 100);
  522.       } else {
  523.         this.onResize(width,height);
  524.       }
  525.  
  526.       if (this.capturedEventsMask & NOF.Event.MOVIE_INITIALIZED_EVENT) {
  527.         this.notifyMovieListeners(new NOF.EventObject(this, NOF.Event.MOVIE_INITIALIZED_EVENT, {w: width, h: height}));
  528.       }
  529.  
  530.       this.log("/PostInit");
  531.     };
  532.  
  533.  
  534.     /*
  535.      * Resizes this Flash's associated footprint to current movie dimensions.
  536.      *
  537.      * @param width new width value
  538.      * @param height new height value
  539.     */
  540.     method.doInitialPositioning = function (width, height) {
  541.       var footprint = this.getFootprint();
  542.       if (footprint) {
  543.         this.setStyle("width",width + "px", footprint);
  544.         this.setStyle("height", height + "px", footprint);
  545.  
  546.         //@todo: save the footprint dimension here for later use. currently not needed.
  547.         var position = this.getObjectPosition(footprint);
  548.         this.onMove(position[0], position[1]);
  549.         this.onResize(width,height);
  550.         this.bReady = true;
  551.       }
  552.     };
  553.  
  554.  
  555.     method.doPostInitCallBack = function ()
  556.     {
  557.       if ( typeof(this.postInitCallBack) == 'object'
  558.           && this.postInitCallBack != null
  559.           && typeof(this.postInitCallBack.callback_handler) == 'function' )
  560.       {
  561.         this.postInitCallBack.callback_handler('PostInit');
  562.       };
  563.     }
  564.  
  565.     /*
  566.      * Instructs Flash to resume playing by calling Play method
  567.      *
  568.      * @param postInitCallBack object reference implementing callback_handler interface.
  569.      *        Callback will be executed after PostInit event is completed
  570.     */
  571.     method.play = function (postInitCallBack) {
  572.       this.postInitCallBack = postInitCallBack;
  573.       try {
  574.         this.getHtmlInstance().Play();
  575.     } catch (e) {}
  576.       this.log("playing");
  577.     };
  578.  
  579.     /*
  580.      * Returns an HTML string suitable for injecting in the host page
  581.     */
  582.     method.toHTML = function () {throw "Abstract method 'toHTML' cannot called!";};
  583.  
  584.     /*
  585.      * Writes the HTML representation of this instance into current document position
  586.     */
  587.  
  588.     method.write = function () {
  589.         if (!this.isWritten) {
  590.           this.htmlDocument.write(this.toHTML());
  591.           this.isWritten = true;
  592.         } else {
  593.           throw "write method cannot be called twice!";
  594.         }
  595.     };
  596.  
  597.     /*
  598.      *
  599.     */
  600.     method.findObject = function (objectID, doc) {
  601.       var p, i, foundObj;
  602.  
  603.       if(!doc) {
  604.         doc = this.htmlDocument;
  605.       }
  606.  
  607.       if( (p = objectID.indexOf("?")) > 0 && parent.frames.length) {
  608.         doc = parent.frames[objectID.substring(p+1)].document;
  609.         objectID = objectID.substring(0,p);
  610.       }
  611.  
  612.       if(!(foundObj = doc[objectID]) && doc.all) {
  613.           foundObj = doc.all[objectID];
  614.       }
  615.  
  616.       for (i=0; !foundObj && i < doc.forms.length; i++) {
  617.         foundObj = doc.forms[i][objectID];
  618.       }
  619.  
  620.  
  621.       for(i=0; !foundObj && doc.layers && i < doc.layers.length; i++) {
  622.         foundObj = this.findObject(objectID, doc.layers[i].document);
  623.       }
  624.  
  625.  
  626.       if(!foundObj && doc.getElementById) {
  627.           foundObj = doc.getElementById(objectID);
  628.       }
  629.  
  630.       return foundObj;
  631.     };
  632.  
  633.     /*
  634.      *
  635.     */
  636.     method.getObjectPosition = function (o) {
  637.       var curLeft = 0;
  638.       var curTop  = 0;
  639.  
  640.       if (o.offsetParent) {
  641.         while (o.offsetParent) {
  642.           curLeft += o.offsetLeft;
  643.           curTop  += o.offsetTop;
  644.           o = o.offsetParent;
  645.         }
  646.       } else if (o.x && o.y) {
  647.         curLeft += o.x;
  648.         curTop  += o.y;
  649.       }
  650.  
  651.       return [curLeft, curTop];
  652.     };
  653.  
  654.     method.getListenerByType = function (type) {
  655.       var listeners;
  656.       if (type == this.MOUSE_LISTENER)
  657.         listeners = this.mouseListeners;
  658.       else if (type == this.MOVIE_LISTENER)
  659.         listeners = this.movieListeners;
  660.       else {
  661.         alert ("Listener not supported.");
  662.         return null;
  663.       }
  664.       return listeners;
  665.     };
  666.  
  667.     method.addListener = function ( type, listener) {
  668.       var listeners = this.getListenerByType(type);
  669.       if (listeners != null) {
  670.         for (var i=0; i<listeners.length; i++)
  671.           if ( listeners[i] == listener )
  672.             return;
  673.  
  674.         listeners[listeners.length] = listener;
  675.       }
  676.     };
  677.  
  678.     method.removeListener = function ( type, listener ){
  679.       var listeners = this.getListenerByType(type);
  680.       if (listeners != null) {
  681.         for (var i = 0; i < listeners.length; i++ )
  682.           if ( listeners[i] == listener ) {
  683.             listeners[i] = listeners[listeners.length -1];
  684.             listeners.length--;
  685.           }
  686.       }
  687.     };
  688.  
  689.     /*
  690.      * Movie listeners management
  691.     */
  692.     method.addMovieListener = function ( listener ){
  693.       this.addListener(this.MOVIE_LISTENER, listener);
  694.     };
  695.  
  696.     method.removeMovieListener = function ( listener ){
  697.       this.removeListener(this.MOVIE_LISTENER, listener);
  698.     };
  699.  
  700.     method.notifyMovieListeners = function ( event ){
  701.       for (var i = 0; i < this.movieListeners.length; i++ ) {
  702.         switch  (event.getType()) {
  703.           case NOF.Event.MOVIE_INITIALIZED_EVENT:
  704.             this.movieListeners[i].onMovieInitialized( event );
  705.             break;
  706.         }
  707.       }
  708.     };
  709.  
  710.     /*
  711.      * Mouse listeners management
  712.     */
  713.     method.addMouseListener = function ( listener ){
  714.       this.addListener(this.MOUSE_LISTENER, listener);
  715.     };
  716.  
  717.     method.removeMouseListener = function ( listener ){
  718.       this.removeListener(this.MOUSE_LISTENER, listener);
  719.     };
  720.  
  721.     method.notifyMouseListeners = function ( event ){
  722.       for (var i = 0; i < this.mouseListeners.length; i++ ) {
  723.         switch  (event.getType()) {
  724.           case NOF.Event.MOUSEDOWN_EVENT:
  725.             this.mouseListeners[i].onMouseDown( event );
  726.             break;
  727.  
  728.           case NOF.Event.MOUSEUP_EVENT:
  729.             this.mouseListeners[i].onMouseUp( event );
  730.             break;
  731.  
  732.           case NOF.Event.MOUSEMOVE_EVENT:
  733.             this.mouseListeners[i].onMouseMove( event );
  734.             break;
  735.  
  736.         }
  737.       }
  738.     };
  739.  
  740.     method.captureEvents = function(eventsMask) {
  741.       this.capturedEventsMask = eventsMask;
  742.     };
  743.  
  744.     /*
  745.      *
  746.     */
  747.     method.onMouseDown = function (_x, _y, _btn, _cnt) {
  748.       if (this.capturedEventsMask & NOF.Event.MOUSEDOWN_EVENT) {
  749.         this.notifyMouseListeners(new NOF.EventObject(this, NOF.Event.MOUSEDOWN_EVENT, {x: _x, y: _y, btn: _btn, cnt: _cnt}));
  750.         this.log(["mouse down", _x, _y, _btn, _cnt]);
  751.       }
  752.     };
  753.  
  754.     /*
  755.      *
  756.     */
  757.     method.onMouseUp = function (_x, _y) {
  758.       if (this.capturedEventsMask & NOF.Event.MOUSEUP_EVENT) {
  759.         this.notifyMouseListeners(new NOF.EventObject(this, NOF.Event.MOUSEUP_EVENT, {x: _x, y: _y}));
  760.         this.log(["mouse up", _x, _y]);
  761.       }
  762.     };
  763.  
  764.     /*
  765.      *
  766.     */
  767.     method.onMouseMove = function (_x, _y) {
  768.       if (this.capturedEventsMask & NOF.Event.MOUSEMOVE_EVENT) {
  769.         this.notifyMouseListeners(new NOF.EventObject(this, NOF.Event.MOUSEMOVE_EVENT, {x: _x, y: _y}));
  770.         this.log(["mouse move", _x,_y]);
  771.       }
  772.     };
  773.  
  774.     /*
  775.      *
  776.     */
  777.     method.onLog = function (msg, level) {
  778.       this.log(msg, level);
  779.     };
  780.  
  781.     /*
  782.      *
  783.     */
  784.     method.log = function (msg, level) {
  785.         if (this.htmlDocument.forms[0] && this.htmlDocument.forms[0]["log"]) {
  786.           this.htmlDocument.forms[0]["log"].value += this.id + ": " + msg + "\n";
  787.         }
  788.     };
  789.  
  790.     /*
  791.      *
  792.     */
  793.     method.setRequiredPlayerVersion = function (reqPlayerVersion) {
  794.       this.requiredPlayerVersion = reqPlayerVersion;
  795.     };
  796.  
  797.     /*
  798.      * Dispatches the <code>eventName</code> to the on$EventName(<code>args</code>) handler
  799.      *
  800.      * @param command the event name
  801.      * @param args the arguments event state
  802.     */
  803.     method.processFSCEvent = function (eventName, args) {
  804.       this.log("processFSCEvent -> " +  eventName + "[" + args + "]");
  805.       var auxStr = "";
  806.       for (var i=0; i<args.length; i++) {
  807.         auxStr += "args[" + i + "]" + (i != args.length -1 ? ", " : "");
  808.       }
  809.  
  810.       return eval("this.on" + eventName + "( " + auxStr + " )");
  811.     };
  812.  
  813.     /*
  814.      * Calls the <code>methodName</code> method of the movie w/ the <code>arg</code> argument
  815.      *
  816.      * @param methodName
  817.      * @param arg
  818.     */
  819.     method.callFlashMethod = function (methodName, arg) {
  820.       try {
  821.         this.getHtmlInstance().SetVariable("hostEventsMonitor", methodName + ":" + arg);
  822.       } catch (e) {}
  823.     };
  824.  
  825.     /*
  826.      * Returns the highest index of all elements on current page + 1
  827.      *
  828.      * @return highestIndex + 1
  829.      *
  830.      * @note currently returns a constant high value considered safe to be the highest
  831.     */
  832.     method.getNextHighestIndex = function() {
  833.       return this.DEFAULT_HIGHEST_ZINDEX;
  834.     }
  835.  
  836.     method.adjustZIndexOnSizeChange = function (width, height) {
  837.       if (Math.abs(this.closedMenuSize.width - width) > this.cDELTA
  838.           || Math.abs(this.closedMenuSize.height - height) > this.cDELTA)
  839.       {
  840.         //find parent layer. set the zIndex to something really high
  841.         var parentLYR = this.getParentLYR();
  842.         if (parentLYR) {
  843.           this.log("setting high Z-Index on flyouts");
  844.           this.setStyle("zIndex", this.getNextHighestIndex(), parentLYR);
  845.         }
  846.       }
  847.       else
  848.       {
  849.         //reset the z-index to normal value
  850.         if (this.parentZIndex != null) {
  851.           var parentLYR = this.getParentLYR();
  852.           if (parentLYR) {
  853.             this.log("setting Z-Index on original size to " + this.parentZIndex);
  854.             this.setStyle("zIndex", this.parentZIndex, parentLYR);
  855.           }
  856.         }
  857.       }
  858.     }
  859.  
  860.   }
  861.  
  862.   function NOF_Flash_HtmlCtrl_IE(id, movieSrc, width, height, align, htmlDocument){
  863.     this.__proto__  = NOF_Flash_HtmlCtrl_IE.prototype;
  864.     this.ctr(id, movieSrc, width, height, align, htmlDocument);
  865.   }
  866.   NOF_Flash_HtmlCtrl_IE.prototype = new NOF_Flash_HtmlCtrl_Base;
  867.  
  868.   //@todo: define the generators for IE
  869.   {
  870.     var method = NOF_Flash_HtmlCtrl_IE.prototype;
  871.  
  872.     /*
  873.       Returns an HTML string that has the FSCommand scripting hooks
  874.     */
  875.     method.getFSCommandHandlerDef = function() {
  876.       var str = "";
  877.  
  878.       str += "<script>";
  879.       str += " function " + this.id +"_DoFSCommand(command, argsStr) {";
  880.       str += "var args;\n";
  881.       str += "if (typeof argsStr == 'object') { args = argsStr;} else {eval ('args = ' + argsStr + ';');}\n";
  882.  
  883.       str += " NOF.Flash.MovieCollectionMgr.getCollection(" + this.owner.getId() + ").getMovieById('" + this.id + "').processFSCEvent(command, args);";
  884.       str += "}";
  885.       str += "\<\/script\>";
  886.  
  887.       str += "<script event=\"FSCommand\" for=" + "\"" + this.id + "\">";
  888.       str += "var args;\n";
  889.       str += "if (typeof arguments[1] == 'object') { args = arguments[1];} else {eval ('args = ' + arguments[1] + ';');}\n";
  890.  
  891.       str += this.id +"_DoFSCommand(arguments[0], args);";
  892.       str += "\<\/script\>";
  893.  
  894.       return str;
  895.     }
  896.  
  897.     /*
  898.       Returns an HTML string suitable for injecting in the host page
  899.     */
  900.     method.toHTML = function () {
  901.       var htmlStr = "";
  902.  
  903.       if (this.isFSCEventsSupportEnabled) {
  904.         htmlStr = this.getFSCommandHandlerDef();
  905.       }
  906.  
  907.       htmlStr += '<OBJECT CLASSID="CLSID:D27CDB6E-AE6D-11cf-96B8-444553540000"';
  908.       htmlStr += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + this.requiredPlayerVersion + '"';
  909.       htmlStr += ' WIDTH="' + this.width +'" HEIGHT="'+ this.height +'" ID="'+ this.id +'">'  + "\n";
  910.         htmlStr += '<PARAM NAME="movie" VALUE="' + this.movieSrc + '" />'  + "\n";
  911.  
  912.         for(var key in this.params) {
  913.             htmlStr += '<PARAM NAME="' + key + '" VALUE="' + this.params[key] + '" />' + "\n";
  914.         }
  915.  
  916.         //default availability is assummed none on SWF side
  917.         if (NOF.Flash.HtmlCtrl.getPlatform() == NOF.Flash.HtmlCtrl.PLATFORM_WINDOWS) {
  918.           this.variables["nof_isFSCommandAvailable"] = true;
  919.         }
  920.  
  921.         //pass in events capturing request if any
  922.         if (this.capturedEventsMask) {
  923.           this.variables["nof_capturedEventsMask"] = this.capturedEventsMask;
  924.         }
  925.  
  926.         this.variables["nof_objectID"] = this.id;
  927.  
  928.         var flashVars = "";
  929.         for(var key in this.variables) {
  930.             flashVars = key + "=" + escape(this.variables[key]) + (flashVars.length == 0 ? "" : "&") + flashVars;
  931.         }
  932.  
  933.         delete this.variables["nof_isFSCommandAvailable"];
  934.         delete this.variables["nof_capturedEventsMask"];
  935.         delete this.variables["nof_objectID"];
  936.  
  937.         if(flashVars.length > 0) {
  938.           htmlStr += '<PARAM NAME="FlashVars" VALUE="'+ flashVars +'" />'  + "\n";
  939.         }
  940.  
  941.       htmlStr += '</OBJECT>' + "\n";
  942.  
  943.       return htmlStr;
  944.     };
  945.  
  946.   }
  947.  
  948.   function NOF_Flash_HtmlCtrl_NetscapeGeneric(id, movieSrc, width, height, align, htmlDocument){
  949.     this.__proto__  = NOF_Flash_HtmlCtrl_NetscapeGeneric.prototype;
  950.     this.ctr(id, movieSrc, width, height, align, htmlDocument);
  951.   }
  952.   NOF_Flash_HtmlCtrl_NetscapeGeneric.prototype = new NOF_Flash_HtmlCtrl_Base;
  953.   {
  954.     var method = NOF_Flash_HtmlCtrl_NetscapeGeneric.prototype;
  955.     method.PARAM_SWLIVECONNECT        = "swliveconnect";
  956.  
  957.     /*
  958.      * Resizes current Flash placeholder on page by updating the html attribute
  959.      *
  960.      * @param width new width value
  961.      * @param height new height value
  962.     */
  963.     method.super_onResize = method.onResize;
  964.     method.onResize = function (width, height) {
  965.       this.super_onResize(width, height);
  966.  
  967.       var htmlInstance = this.getHtmlInstance();
  968.       if (htmlInstance) {
  969.         this.setStyle("width",width + "px", htmlInstance);
  970.         this.setStyle("height", height + "px", htmlInstance);
  971.       }
  972.     };
  973.  
  974.     /*
  975.       Returns an HTML string suitable for injecting in the host page
  976.     */
  977.     method.toHTML = function () {
  978.       var htmlStr = "";
  979.  
  980.       if (this.isFSCEventsSupportEnabled) {
  981.         htmlStr += "<script language=JavaScript>\n";
  982.         htmlStr += " function " + this.id +"_DoFSCommand(command, strArgs) {\n";
  983.         htmlStr += " NOF.Flash.MovieCollectionMgr.getCollection(" + this.owner.getId() + ").getMovieById('" + this.id + "').processFSCEvent(command, strArgs);";
  984.         htmlStr += "}\n";
  985.         htmlStr += "</script>\n";
  986.       }
  987.  
  988.       //@todo: check for the current plugin version and replace w/ an upgrade text message
  989.       htmlStr += '<EMBED TYPE="application/x-shockwave-flash"';
  990.       htmlStr += ' pluginspage="http://www.macromedia.com/go/getflashplayer"';
  991.       htmlStr += ' SRC="'+ this.movieSrc +'" WIDTH="'+ this.width +'" HEIGHT="'+ this.height +'" ID="'+ this.id + '" NAME="'+ this.id +'"';
  992.         for(var key in this.params) {
  993.           if (typeof this.params[key] != 'function') {
  994.             htmlStr += " " + key + '=' + this.params[key];
  995.           }
  996.         }
  997.  
  998.         var flashVars = "";
  999.         //pass in events capturing request if any
  1000.         if (this.capturedEventsMask) {
  1001.           this.variables["nof_capturedEventsMask"] = this.capturedEventsMask;
  1002.         }
  1003.         this.variables["nof_objectID"] = this.id;
  1004.  
  1005.         for(var key in this.variables) {
  1006.           if (typeof this.variables[key] != 'function') {
  1007.             flashVars = key + "=" + escape(this.variables[key]) + (flashVars.length == 0 ? "" : "&") + flashVars;
  1008.           }
  1009.         }
  1010.  
  1011.         delete this.variables["nof_capturedEventsMask"];
  1012.         delete this.variables["nof_objectID"];
  1013.  
  1014.         if(flashVars.length > 0) {
  1015.           htmlStr += ' FlashVars="'+ flashVars + '"';
  1016.         }
  1017.  
  1018.       htmlStr += '>';
  1019.       htmlStr += '</EMBED>';
  1020.  
  1021.       return htmlStr;
  1022.     };
  1023.  
  1024.   }
  1025.  
  1026.   function isHostNetscapeCompatible() {return navigator.mimeTypes.length ? true : false;};
  1027.   function isHostActiveXCompatible() { return window.ActiveXObject ? true : false; };
  1028.  
  1029.  
  1030.   if (isHostActiveXCompatible()) {
  1031.     NOF.Flash.HtmlCtrl = NOF_Flash_HtmlCtrl_IE;
  1032.   } else {
  1033.     NOF.Flash.HtmlCtrl = NOF_Flash_HtmlCtrl_NetscapeGeneric;
  1034.   }
  1035.  
  1036.   //Static methods go here
  1037.  
  1038.   NOF.Flash.HtmlCtrl.PLATFORM_WINDOWS = "Windows";
  1039.   NOF.Flash.HtmlCtrl.PLATFORM_MAC     = "Mac";
  1040.   NOF.Flash.HtmlCtrl.PLATFORM_UNKNOWN = "Unknown";
  1041.  
  1042.   /*
  1043.    * Not entirely reliable. Navigator.platform is not always populated. Need to guess it from appVersion or userAgent
  1044.   */
  1045.   NOF.Flash.HtmlCtrl.getPlatform = function () {
  1046.     if ((navigator.platform && navigator.platform.substring(0,3) == "Win")
  1047.         || navigator.appVersion.indexOf("Windows") != -1 ) {
  1048.       return NOF.Flash.HtmlCtrl.PLATFORM_WINDOWS;
  1049.     } else  if ((navigator.platform && navigator.platform.substring(0,3) == "Mac")
  1050.         || navigator.appVersion.indexOf("Macintosh") != -1 ) {
  1051.       return NOF.Flash.HtmlCtrl.PLATFORM_MAC;
  1052.     }
  1053.  
  1054.     return NOF.Flash.HtmlCtrl.PLATFORM_UNKNOWN;
  1055.   };
  1056.  
  1057.   /*
  1058.     Returns true if browser support Netscape Plugin Architecture
  1059.   */
  1060.   NOF.Flash.HtmlCtrl.isHostNetscapeCompatible = isHostNetscapeCompatible;
  1061.  
  1062.   /*
  1063.     Returns true if browser supports ActiveXObject method. Currently IE only
  1064.   */
  1065.   NOF.Flash.HtmlCtrl.isHostActiveXCompatible = isHostActiveXCompatible;
  1066.  
  1067.   /*
  1068.    * Queries the host browser for version information (major, minor, revision)
  1069.    *
  1070.    * @return a ProgramVersion reference
  1071.    * @see ProgramVersion
  1072.   */
  1073.   NOF.Flash.HtmlCtrl.getCurrentPlayerVersion = function () {
  1074.     if (NOF.Flash.HtmlCtrl.playerVersion == null) {
  1075.       var playerVer = new NOF.ProgramVersion(0,0,0);
  1076.  
  1077.       if(NOF.Flash.HtmlCtrl.isHostNetscapeCompatible() ) {
  1078.         var plugin = navigator.plugins[member.NETSCAPE_PLUGIN_NAME];
  1079.         if (plugin && plugin.description) {
  1080.           var parts = plugin.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")
  1081.           playerVer = new NOF.ProgramVersion(parts[0], parts[1], parts[2]);
  1082.         }
  1083.       } else if (NOF.Flash.HtmlCtrl.isHostActiveXCompatible()) {
  1084.          try {
  1085.             var player = new ActiveXObject(member.IE_PLUGIN_NAME);
  1086.             var parts = player.GetVariable("$version").split(" ")[1].split(",");
  1087.             playerVer = new NOF_ProgramVersion(parts[0], parts[1], parts[2]);
  1088.          } catch (e) {}
  1089.       }
  1090.  
  1091.       NOF.Flash.HtmlCtrl.playerVersion  = playerVer;
  1092.     }
  1093.  
  1094.     return NOF.Flash.HtmlCtrl.playerVersion;
  1095.   };
  1096.  
  1097.   /*
  1098.    * Takes current page to <code>url</code> if targetWindow is empty or _self
  1099.    * Otherwise opens a new window at <code>url</code>
  1100.    *
  1101.    * @param url
  1102.    * @param targetName
  1103.   */
  1104.   NOF.Flash.HtmlCtrl.launchURL = function (args) {
  1105.     var url = args[0];
  1106.     var targetName = args[1];
  1107.  
  1108.     var windowRef = null;
  1109.     if (targetName == undefined || targetName == null || targetName == "") {
  1110.           if ( document.getElementsByTagName )
  1111.           {
  1112.             var coll = document.getElementsByTagName('BASE');
  1113.             if ( coll && coll.length && coll.length > 0 )
  1114.               targetName = coll[0].target;
  1115.  
  1116.             if ( targetName == undefined || targetName == "" )
  1117.                 windowRef = window;
  1118.           }
  1119.     }
  1120.  
  1121.     if (windowRef == null) {
  1122.       switch (targetName)
  1123.       {
  1124.         case undefined:
  1125.         case null:
  1126.         case "":
  1127.           if ( document.getElementsByTagName )
  1128.           {
  1129.           var coll = document.getElementsByTagName('BASE');
  1130.           if ( coll && coll.length && coll.length > 0 )
  1131.             targetName = coll[0].target;
  1132.  
  1133.           if ( targetName == undefined || targetName == "" )
  1134.             windowRef = window;
  1135.           }
  1136.  
  1137.           if (windowRef != null) //stop if we found our window. otherwise keep searching
  1138.           break;
  1139.  
  1140.         case "_self" :
  1141.           windowRef = window;
  1142.           break;
  1143.  
  1144.         case "_parent" :
  1145.           windowRef = parent;
  1146.           break;
  1147.  
  1148.         case "_top" :
  1149.           windowRef = top;
  1150.           break;
  1151.  
  1152.         case "_blank" :
  1153.           break;
  1154.  
  1155.         default:
  1156.           windowRef = NOF.Util.GetFrameWndByName(targetName);
  1157.           break;
  1158.       }
  1159.     }
  1160.  
  1161.     if (windowRef != null) {
  1162.         windowRef.location.href = url;
  1163.     } else {
  1164.         window.open(url, targetName);
  1165.     }
  1166.   };
  1167.  
  1168. }
  1169.  
  1170. if(typeof NOF.Flash.MovieCollectionMgr == "undefined")
  1171. {
  1172.   function NOF_Flash_MovieCollectionMgr() {
  1173.     this.__proto__ = NOF_Flash_MovieCollectionMgr.prototype;
  1174.     this.collections = new Array();
  1175.   }
  1176.  
  1177.   var method = NOF_Flash_MovieCollectionMgr.prototype;
  1178.  
  1179.   method.createCollection  = function() {
  1180.     var coll = new NOF.Flash.MovieCollection(this.collections.length);
  1181.     this.collections[this.collections.length] = coll;
  1182.  
  1183.     return coll;
  1184.   };
  1185.  
  1186.   method.getCollection = function(index) {
  1187.     return (index>=0 && index<this.collections.length) ? this.collections[index] : null;
  1188.   };
  1189.  
  1190.   NOF.Flash.__proto__.MovieCollectionMgr = new NOF_Flash_MovieCollectionMgr();
  1191. }
  1192.  
  1193. if(typeof NOF.Flash.MovieCollection == "undefined")
  1194. {
  1195.   function NOF_Flash_MovieCollection (id) {
  1196.     this.__proto__ = NOF_Flash_MovieCollection.prototype;
  1197.  
  1198.     this.id         = id;
  1199.     this.movies     = new Array();
  1200.     this.moviesHash = new Array();
  1201.     this.currentMovieIndex = 0;
  1202.   }
  1203.  
  1204.   var method = NOF_Flash_MovieCollection.prototype;
  1205.  
  1206.   method.createMovie  = function (id, src, width, height) {
  1207.     var movie = new NOF.Flash.HtmlCtrl(id, src, width, height);
  1208.  
  1209.     movie.setOwner(this);
  1210.     this.movies[this.movies.length] = movie;
  1211.     this.moviesHash[id] = movie;
  1212.  
  1213.     return movie;
  1214.   };
  1215.  
  1216.   method.getId = function () {
  1217.     return this.id;
  1218.   }
  1219.  
  1220.   method.getMovieById = function (id) {
  1221.     return this.moviesHash[id];
  1222.   }
  1223.  
  1224.   method.getMovieByIndex = function (index) {
  1225.     return (index>=0 && index<this.movies.length) ? this.movies[index] : null;
  1226.   }
  1227.  
  1228.   method.startAll  = function () {
  1229.     if (this.currentMovieIndex < this.movies.length) {
  1230.       this.movies[this.currentMovieIndex++].play(this);
  1231.     } else {
  1232.       this.setZIndex();
  1233.     }
  1234.   };
  1235.  
  1236.   method.resizeAll =   function () {
  1237.     var i=0;
  1238.     while (i < this.movies.length) {
  1239.       this.movies[i++].repaint();
  1240.     }
  1241.     this.setZIndex();
  1242.   }
  1243.  
  1244.   method.setZIndex  = function () {
  1245.     var maxTop = 0;
  1246.     for (var i=0; i<this.movies.length; i++) {
  1247.       var pos = this.movies[i].getPosition();
  1248.       if (maxTop < pos.top) {maxTop = pos.top}
  1249.     }
  1250.  
  1251.     for (i=0;i<this.movies.length; i++) {
  1252.       var pos = this.movies[i].getPosition();
  1253.       this.movies[i].log("setZIndex to " + (-1 * (pos.top - maxTop)));
  1254.       this.movies[i].setStyle("zIndex", -1 * (pos.top - maxTop));
  1255.     }
  1256.   };
  1257.  
  1258.   method.callback_handler  = function (eventName) {
  1259.     if (eventName == 'PostInit') {
  1260.       this.startAll();
  1261.     }
  1262.   };
  1263.  
  1264.   NOF.Flash.__proto__.MovieCollection = NOF_Flash_MovieCollection;
  1265. }